package com.sy.mapper;

import com.sy.dto.HomeworkMagTable;
import com.sy.dto.SubmitStudentMsg;
import com.sy.entity.*;
import com.sy.vo.ChoiceVo;
import com.sy.vo.HomeworkVo;
import com.sy.vo.QuestionsVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface HomeworkMapper {
    /**
     *  添加作业
     */
     boolean addHomework(@Param("vo") HomeworkVo homeworkVo,@Param("id") Integer teacherId);
    /**
     *  根据作业标题查作业的id
     */
    Integer getHomeworkIdByTitle(@Param("vo") HomeworkVo homeworkVo,@Param("id")Integer teacherId);

    /**
     *添加简答题
     */
   boolean addShortQuestion(@Param("vo") HomeworkVo homeworkVo,@Param("id") Integer homeworkId);
    /**
     * 添加选择题
     */
    boolean addChoiceQuestions(@Param("vo")QuestionsVo questionsVo,@Param("id") Integer homeworkId);
    /**
     * 根据选择题干查对应的id
     */
    Integer getChoiceQuestionIdByQuestion(@Param("vo") QuestionsVo questionsVo);
    /**
     * 根据选择题id添加对应的选项
     */
    boolean addChoices(@Param("vo")ChoiceVo choiceVo,@Param("id") Integer choiceQuestionId);

    /**
     *根据答案选项的内容获得对应的id
     */
    Integer getAnswerChoiceIdByAnswer(@Param("vo")QuestionsVo questionsVo);

    /**
     * 添加标准答案表
     */
    boolean addChoiceAnswer (@Param("homeworkId") Integer homeworkId,@Param("choiceQuestionId") Integer choiceQuestionId,@Param("choiceAnswerId") Integer choiceAnswerId);

    /**
     * 根据老师id获得作业列表
     */
    List<HomeworkMagTable> getHomeworkListByTeacherId(@Param("id") Integer teacherId,@Param("keyWords") String keyWords);
    /**
     * 删除作业
     */
    boolean deleteHomework(@Param("id") Integer homeworkId);
    /**
     * 根据作业id删除简答题
     */
    boolean deleteShortQuestion(@Param("id") Integer homeworkId);
    /**
     * 根据作业id删除提交的选择题答案
     */
    boolean deleteChoiceAnswerSubmit(@Param("id") Integer homeworkId);
    /**
     * 根据作业id删除选择题标准答案
     */
    boolean deleteChoiceAnswer(@Param("id") Integer homeworkId);
    /**
     * 根据作业id删除分数
     */
    boolean deleteScoreByHomeworkId(@Param("id") Integer homeworkId);

    /**
     * 根据学生的id列表查找已提交的学生id和作业id
     */
    List<SubmitStudentMsg> getHasSubmitStudentsMsg(@Param("vo") List<Integer> studentsIdList);
    /**
     * 根据作业id得到简答题id
     */
    Integer getShortQuestionIdByHomeworkId(Integer homeworkId);
    /**
     * 根据简答题id删除已提交的简答题答案
     */
    boolean deleteShortQuestionSubmitById(Integer shortQuestionId);
    /**
     * 根据作业id查找分数表
     */
    List<Score> getScoreByHomeworkId(@Param("id") Integer homeworkId);
    /**
     * 根据作业id查找选择题提交表
     */
    List<SubmitChoiceAnswer> getSubmitChoiceAnswerByHomeworkId(@Param("id")Integer homeworkId);
   /**
    * 根据简答题id获得提交的简答题
    */
   List<SubmitShortAnswer> getSubmitShortAnswerByShortQuestionId(@Param("id") Integer shortQuestionId);
   /**
    * 根据作业id获得作业信息
    */
   Homework getHomeworkById(Integer homeworkId);
   /**
    * 根据作业id获得简答题
    */
   ShortQuestion getShortQuestionByHomeworkId(Integer homeworkId);
   /**
    * 根据作业id和学生id查找已提交的简答题答案表
    */
   SubmitShortAnswer getSubmitShortAnswer(@Param("homeworkId") Integer homeworkId,@Param("studentId") Integer studentId);
   /**
    * 根据作业id和学生id得出提交选择答案正确的数量
    */
   Integer getCountForTrue(@Param("homeworkId") Integer homeworkId,@Param("studentId") Integer studentId);

   List<Homework> getHomeWorkByTeacherId(Integer teacherId);
    /**
     * 根据作业id获得选择题列表
     */
    List<ChoiceQuestion> getChoicesQuestionByHomeworkId(@Param("id")Integer homeworkId);
    /**
     * 根据选择题id获取选项列表
     */
    List<Choice> getChoicesByQuestionId(@Param("id")Integer questionId);
    /**
     * 根据作业id获取答案实体类
     */
    List<Answer> getAnswer(@Param("id") Integer homeworkId);

}
